import java.awt.Dimension;

import javax.swing.*;

public class ListDemo {

	    public static void main(String[] args) {
	        Person p1 = new Person("Hans", "im Glück");
	        Person p2 = new Person("Klaus", "Müller");
	        
	        DefaultListModel dlm = new DefaultListModel();
	        dlm.addElement(p1);
	        dlm.addElement(p2);
	        
	        JFrame frame = new JFrame("JList Demo");
	        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        
	        JList list = new JList(dlm);
	        list.setPreferredSize(new Dimension(200,300));
	        
	        frame.add(list);
	        frame.pack();
	        frame.setVisible(true);
	    }
	    
	    private static class Person {
	        private String first;
	        private String last;
	        
	        public Person(String first, String last) {
	            this.first = first;
	            this.last = last;
	        }
	        
	        @Override
	        public String toString() {
	            return first + " " + last;
	        }
	    }
	}
	
